/* $Id: memberlist.cc jjs $ */
/*
   Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
   Part of the Moros Project http://moros.sourceforge.net/

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 2 or any
   later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details.
*/
#define DEBUG_ROUTINE "memberlist"

#include "moros.h"
#include "../general/log.h"
#include "../general/channel.h"
#include "memberlist.h"


/**
    \todo add context menu to this list
*/

memberlist::memberlist(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> refGlade)
: Gtk::Window(cobject), m_refGlade(refGlade) {
	memberlist::show();
	m_refGlade->get_widget("members_close", members_close);
	m_refGlade->get_widget("members_whisper", members_whisper);
	m_refGlade->get_widget("members_ignore", members_ignore);
	m_refGlade->get_widget("members_list", members_list);

	list_store = Gtk::ListStore::create(cols);
	members_list->set_model(list_store);
	members_list->set_search_column(cols.name.index());

	int colnr;
	Gtk::TreeViewColumn* col;
	Gtk::CellRendererText* renderer;

	renderer = Gtk::manage( new Gtk::CellRendererText() );
	colnr = members_list->append_column("Name", *renderer);
	col = members_list->get_column(colnr-1);
	col->add_attribute(renderer->property_text(), cols.name);

	renderer = Gtk::manage( new Gtk::CellRendererText() );
	colnr = members_list->append_column("Status", *renderer);
	col = members_list->get_column(colnr-1);
	col->add_attribute(renderer->property_text(), cols.status);

	members_close->signal_clicked().connect(sigc::mem_fun(*this, &memberlist::clicked_close));
	members_whisper->signal_clicked().connect(sigc::mem_fun(*this, &memberlist::clicked_whisper));
	members_ignore->signal_clicked().connect(sigc::mem_fun(*this, &memberlist::clicked_ignore));
}

memberlist::~memberlist() {}

void memberlist::members_clear() {
    list_store->clear();
}

void memberlist::members_show(std::string member, std::string status) {
    Gtk::TreeRow row = *(list_store->append());
    row[cols.name]=member;
    row[cols.status]=status;
}

void memberlist::clicked_close() {
	memberlist::hide();
}

void memberlist::clicked_whisper() {
}

void memberlist::clicked_ignore() {
}
